package com.work.demo.utils;/*
 *@title LogUtil
 *@description
 *@author fulls
 *@version 1.0
 *@create 2025/1/7 18:27
 */

import java.text.Normalizer;
import java.util.ArrayList;
import java.util.List;

public class LogUtil {
    /**
     * Log Forging漏洞校验
     * @param logs
     * @return
     */
    public static String vaildLog(String logs) {
        List<String> list=new ArrayList<String>();
        list.add("%0d");
        list.add("%0a");
        list.add("%0A");
        list.add("%0D");
        list.add("\r");
        list.add("\n");
        String normalize = Normalizer.normalize(logs, Normalizer.Form.NFKC);
        for (String str : list) {
            normalize=normalize.replace(str, "");
        }
        return normalize;
    }
}
